#include<stdio.h>

int main() {
    int t, a, b;
    scanf("%d", &t);
    int times[t];

    for (int i = 0; i < t; i++) {
        scanf("%d %d", &a, &b);
        if (a > b) {
            int tmp = a - b;
            if (tmp % 2 == 0) {
                times[i] = 1;
            } else {
                times[i] = 2;
            }
        } else if (a < b) {
            int tmp = b - a;
            if (tmp % 2 == 0) {
                times[i] = 2;
            } else {
                times[i] = 1;
            }
        } else {
            times[i] = 0;
        }
    }

    for (int i = 0; i < t; i++) {
        printf("%d\n", times[i]);
    }

    return 0;
}